package com.qny.ai.controller;

import com.qny.ai.common.ApiResponse;
import com.qny.ai.util.SystemRoleSQLGenerator;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/system")
@RequiredArgsConstructor
public class SystemRoleController {

    private final SystemRoleSQLGenerator sqlGenerator;

    /**
     * 生成包含头像URL的系统角色SQL
     */
    @GetMapping("/roles/sql")
    public ApiResponse<String> generateSystemRolesSQL() {
        log.info("生成系统角色SQL请求");
        
        try {
            String sql = sqlGenerator.generateSystemRolesSQL();
            log.info("系统角色SQL生成成功，长度: {}", sql.length());
            return ApiResponse.ok(sql);
        } catch (Exception e) {
            log.error("生成系统角色SQL失败: {}", e.getMessage());
            return ApiResponse.fail(500, "生成SQL失败: " + e.getMessage());
        }
    }
}
